package com.gd.iot.energy.service.datamanage.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gd.iot.energy.consts.SystemConsts;
import com.gd.iot.energy.dao.datamanage.EquipInstructiontreePOMapper;
import com.gd.iot.energy.po.datamanage.EquipInstructiontreePO;
import com.gd.iot.energy.service.datamanage.EquipInstructionTreeService;
import org.springframework.stereotype.Service;

/**
 * @author kris
 * @date 2020/8/28 0028 14:16
 */
@Service
public class EquipInstructionTreeServiceImpl extends ServiceImpl<EquipInstructiontreePOMapper, EquipInstructiontreePO> implements EquipInstructionTreeService {


    @Override
    public EquipInstructiontreePO getByState(Long sysconfigEquipmentModelId, String state) {
        QueryWrapper<EquipInstructiontreePO> queryWrapper = new QueryWrapper();
        queryWrapper.eq("equipment_id", sysconfigEquipmentModelId);
        if (SystemConsts.OperateValveStateEnum.CLOSE.value.equals(state)) {
            queryWrapper.eq("tree_method", "valveOff");
        } else {
            queryWrapper.eq("tree_method", "valveOn");
        }
        return getOne(queryWrapper);
    }
}
